package com.rjxy.plansystemmanagement.controller.entityController;

import com.rjxy.plansystemmanagement.entity.HotelOrderInfo;
import com.rjxy.plansystemmanagement.entity.Result.Result;
import com.rjxy.plansystemmanagement.service.HotelOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/HotelOrders")
@Slf4j
public class HotelOrderController {
    @Autowired
    private HotelOrderService hotelOrderService;

    @GetMapping
    public Result list(){
        log.info("查询酒店订单列表");
        List<HotelOrderInfo> hotelOrderInfoList = hotelOrderService.list();
        return Result.success(hotelOrderInfoList);
    }
    @DeleteMapping("/{ID}")
    public Result deleteHotelOrder(@PathVariable Integer ID){
        log.info("根据id{}删除指定酒店订单", ID);
        hotelOrderService.deleteHotelOrder(ID);
        return Result.success();
    }
    @PostMapping
    public Result addHotelOrder(@RequestBody HotelOrderInfo hotelOrderInfo){
        log.info("增加酒店订单");
        hotelOrderService.addHotelOrder(hotelOrderInfo);
        return Result.success();
    }
    @GetMapping("/{ID}")
    public Result getHotelOrderById(@PathVariable Integer ID){
        log.info("根据HotelOrderID查询酒店", ID);
        HotelOrderInfo hotelOrderInfo = hotelOrderService.getHotelOrderById(ID);
        return Result.success(hotelOrderInfo);
    }

    @GetMapping("/UserId/{id}")
    public Result getHotelOrderByUid(@PathVariable Integer id){
        log.info("查询酒店订单列表");
        List<HotelOrderInfo> hotelOrderInfoList = hotelOrderService.getHotelOrderByUid(id);
        return Result.success(hotelOrderInfoList);
    }

    @PutMapping
    public Result updateHotelOrder(@RequestBody HotelOrderInfo hotelOrderInfo){
        hotelOrderService.updateHotelOrder(hotelOrderInfo);
        return Result.success();
    }

    @GetMapping("/Status/{status}")
    public Result getHotelOrderByStatus(@PathVariable String status){
        log.info("查询酒店订单列表");
        List<HotelOrderInfo> hotelOrderInfoList = hotelOrderService.getHotelOrderByStatus(status);
        return Result.success(hotelOrderInfoList);
    }

}
